package org.jeecg.modules.xl.exceltemplate.controller;

import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.xl.exceltemplate.service.ExcelTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * 模版下载控制
 *
 * @author deco
 * @create 2024-10-30
 */
@Api(tags = "模版下载")
@RestController
@RequestMapping("/xl/template")
@Slf4j
public class TemplateDownloadController {

    private String ORDERCREAT = "ordercreate";//订单创建模版

    private String PRODUCTIMPORT = "prodcutimport";//订单创建模版

    private String STOREIMPORT = "storeimport";//订单创建模版

    private String deliverycodeimport="deliveryCodeImport";


    private String importAfterOrder="importAfterOrder";

    private String prodcutcustomerimport="prodcutcustomerimport";


    @Autowired
    private ExcelTemplateService excelTemplateService;
    //@RequiresPermissions("xl:template:download")
    @RequestMapping(value = "/downloadTemplateXls")
    public ModelAndView downloadTemplateXls(HttpServletRequest request, @RequestParam String template) {
        //订单创建模版，对应菜单 采购管理-订单创建->下载模版
        if(ORDERCREAT.equals(template)){
            return excelTemplateService.createOrderTemplate();
        }
        //订单创建模版，对应菜单 基础设置->商品类目->下载模版
        if(PRODUCTIMPORT.equals(template)){
            return excelTemplateService.productImportTemplate();
        }
        //订单创建模版，对应菜单 基础设置->门店管理->下载模版
        if(STOREIMPORT.equals(template)){
            return excelTemplateService.storeImportTemplate();
        }
        //订单创建模版，对应菜单 采购管理->发货管理->已发货
        if(deliverycodeimport.equals(template)){
            return excelTemplateService.deliveryCodeImportTemplate();
        }

        if(importAfterOrder.equals(template)){
            return excelTemplateService.getImportAfterOrderTemplate();
        }
        //客户商品导入
        if(prodcutcustomerimport.equals(template)){
            return excelTemplateService.prodcutcustomerimport();
        }

        return null;
    }
}
